package org.example.gradleauth.controller;

import gradle.common.core.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.example.gradleauth.model.vo.TokenVo;
import org.example.gradleauth.service.TokenService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "token-controller")
@RestController
@RequestMapping("/token")
public class TokenController {

    @Resource
    private TokenService tokenService;

    @Operation(summary = "令牌刷新", method = "POST")
    @PostMapping("/refresh-token")
    public ApiResponse<TokenVo> refreshToken(@RequestHeader("refresh-token") String refreshToken) {

        return ApiResponse.success(tokenService.refreshToken(refreshToken));
    }

}
